import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.sql.RowSet;
import javax.sql.rowset.CachedRowSet;

import com.mysql.jdbc.Statement;
import com.sun.rowset.CachedRowSetImpl;


public class Db {
	private CachedRowSet rs;
	
	public Db(){
		
		System.out.println("hello uncle");
		
		 Connection con = null;

		    try {
		      Class.forName("com.mysql.jdbc.Driver").newInstance();
		      con = DriverManager.getConnection("jdbc:mysql:///test",
		        "root", "");

		      if(!con.isClosed())
		        System.out.println("Successfully connected to " +
		          "MySQL server using TCP/IP...");
		      	
	      		  // fetch data frm the sample tbl
			      Statement st = (Statement) con.createStatement();
			      
			      // connected resultset
			      ResultSet resultSet = st.executeQuery("select * from sample");
			      
			      
			      // disconnected row set
			      rs=new CachedRowSetImpl();
			      rs.populate(resultSet);
			      
		      

		    } catch(Exception e) {
		      System.err.println("Exception: " + e.getMessage());
		    } 
		    finally {
		      try {
			        if(con != null)
			          con.close();
			      } catch(SQLException e) {}
			    }
	}
	
	


	public CachedRowSet getRs() {
		return rs;
	}

	public void setRs(CachedRowSet rs) {
		this.rs = rs;
	}




	public static void main(String args[]) {

		    
	}
}
